/*    */ package com.zimbra.cs.db;
/*    */ 
/*    */ import com.zimbra.common.localconfig.KnownKey;
/*    */ import com.zimbra.common.localconfig.LC;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import java.lang.reflect.Constructor;
/*    */ import java.sql.Connection;
/*    */ import java.sql.SQLException;
/*    */ import java.util.Properties;
/*    */ import org.apache.commons.dbcp.ConnectionFactory;
/*    */ import org.apache.commons.dbcp.DriverManagerConnectionFactory;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class ZimbraConnectionFactory
/*    */   extends DriverManagerConnectionFactory
/*    */ {
/* 37 */   private static ConnectionFactory sConnFactory = null;
/*    */   
/* 39 */   public static ConnectionFactory getConnectionFactory(DbPool.PoolConfig pconfig) { if (sConnFactory == null) {
/* 40 */       String className = LC.zimbra_class_dbconnfactory.value();
/* 41 */       if ((className != null) && (!className.equals(""))) {
/*    */         try {
/* 43 */           ZimbraLog.dbconn.debug("instantiating DB connection factory class " + className);
/* 44 */           Class clazz = Class.forName(className);
/* 45 */           Constructor constructor = clazz.getDeclaredConstructor(new Class[] { String.class, Properties.class });
/* 46 */           sConnFactory = (ConnectionFactory)constructor.newInstance(new Object[] { pconfig.mConnectionUrl, pconfig.mDatabaseProperties });
/*    */         } catch (Exception e) {
/* 48 */           ZimbraLog.system.error("could not instantiate database connection pool '" + className + "'; defaulting to ZimbraConnectionFactory", e);
/*    */         }
/*    */       }
/* 51 */       if (sConnFactory == null)
/* 52 */         sConnFactory = new ZimbraConnectionFactory(pconfig.mConnectionUrl, pconfig.mDatabaseProperties);
/*    */     }
/* 54 */     return sConnFactory;
/*    */   }
/*    */   
/*    */   ZimbraConnectionFactory(String connectUri, Properties props) {
/* 58 */     super(connectUri, props);
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */   public Connection createConnection()
/*    */     throws SQLException
/*    */   {
/* 67 */     Connection conn = super.createConnection();
/* 68 */     Db.getInstance().postCreate(conn);
/* 69 */     return new DebugConnection(conn);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/db/ZimbraConnectionFactory.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */